<?php

namespace App\Api\Controllers;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redis;

/**
 * 系统设置
 * Class SystemController
 * @package App\Api\Controllers
 */
class AboutusController extends Controller
{
    public function index()
    {
        if(empty($content = json_decode(Redis::get('about_us'), true))){

            $content=  D('info')->get(['content']);
            Redis::setex('about_us', 3600, $content);
        }

        return json_success('ok', $content, 10000);
    }
    public function get_all_bg_picture()
    {
        $data = D('users_bg_picture')->get(['id','img']);
        return json_success('ok', $data, 10000);
    }
    //设置背景图片
    public function set_user_picture(Request $request){
        $user_id = IT('user_id',true,'请输入用户id', 10002);
        $picture_id = IT('picture_id',true,'请输入图片id', 10003);
        $data = D('users')->where('id',$user_id)->update(['user_bg_picture'=>$picture_id]);
        return json_success('ok', $data, 10000);
    }

}